package com.shujia.java.day4;

import java.util.Arrays;
import java.util.Scanner;

public class Demo3Array {
    public static void main(String[] args) {

        /**
         * 键盘输入小明的成绩
         * 将成绩存到数组中
         */

        int[] score = new int[5];

        Scanner sc = new Scanner(System.in);

        for (int i = 0; i < score.length; i++) {
            System.out.println("请输入第 " + (i + 1) + "门科目的分数");
            int s = sc.nextInt();

            //将分数存到数组中
            score[i] = s;

        }

        //打印输出
        System.out.println(Arrays.toString(score));

        /**
         * 1、计算总分
         *
         */

        int sum = 0;

        for (int i = 0; i < score.length; i++) {
            sum = sum + score[i];
        }

        System.out.println(sum);

        double avg = (double) sum / score.length;
        System.out.println("平均分为：" + avg);


    }
}
